package cn.itcast.blog.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.itcast.blog.domain.Category;
import cn.itcast.blog.service.CategoryService;

/**
 * 接受请求，解析参数，调用service处理业务逻辑，返回响应
 * @author 16604
 *
 */

public class CategoryServlet extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		CategoryService service = new CategoryService();
		
		Category category = new Category();
		
		//接受传过来的请求
		String name = req.getParameter("name");
		
		//解决乱码问题，这里有个小问题，用set设置不了
		String parameter = new String(name.getBytes("ISO8859-1"),"utf-8");
		
		category.setName(parameter);
		
		service.insertCategory(category);
		
		System.out.println(parameter);
		
	}
	
}
